#include "imgui/font/Editor.h"

bool ImGui::Font::Editor::Edit(Ogl::Font::TextLine& inst, const std::vector<std::string>& fontFamilys)
{
	if (inst.m_FontFamily.empty() && fontFamilys.size() > 0)
	{
		inst.m_FontFamily = fontFamilys[0];
	}
	bool res = false;

	ImGui::PushID(&inst);

	ImGui::DragFloat2("pos", &inst.m_Pos.x);
	ImGui::DragInt("fontSize", &inst.m_FontSize, 1.0f, 5);
	if (inst.m_FontSize < 5)
	{
		inst.m_FontSize = 5;
	}
	ImGui::ColorEdit3("fontColor", &inst.m_TextColor.x);
	m_StringEditor.InputString("Text", inst.m_Text);
	inst.m_Text = inst.m_Text.c_str();

	if (ImGui::BeginCombo("Family", inst.m_FontFamily.c_str()))
	{

		for (const auto& it : fontFamilys)
		{
			if (ImGui::Selectable(it.c_str(), inst.m_FontFamily == it))
			{
				inst.m_FontFamily = it;
			}
		}
		ImGui::EndCombo();
	}
	ImGui::PopID();
	return res;
}

